home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 May / macformat-024.iso / Shareware City / Developers / TransSkel Pascal 2.5 / TransSkel / MultiSkel ƒ / MultiSkel.p < prev    next >
Encoding:
Text File  |  1994-12-05  |  4.0 KB  |  149 lines  |  [TEXT/PJMM]

  1. {    TransSkel multiple-window demonstration: main module}
  2.  
  3. {    This module performs setup and termination operations, installs}
  4. {    the window and menu handlers, and processes menu item selections.}
  5.  
  6. {    There are four window handlers in this demonstration.  The code}
  7. {    for each handler is in its own module.}
  8.  
  9. {    Help Window        Scrollable non-editable text window}
  10. {    Edit Window        Non-scrollable editable text window}
  11. {    Zoom Window        Non-manipulable graphics display window}
  12. {    Region Window    Manipulable graphics display window}
  13.  
  14. {    The project should include RunTime.lib,Interface.lib, TransSkel.p (or a library built}
  15. {    from TransSkel.p), MSkelHelp.p, MSkelEdit.p, MSkelZoom.p and}
  16. {    MSkelRgn.p.  You'll also need the MultiSkel.globals.p and common.p header files.}
  17. {    You'll also need to set the resource file to MultiSkel.proj.rsrc.}
  18.  
  19. {    24 June 1986        Paul DuBois}
  20. {    8 January 1987     Ported to LightSpeed Pascal by Owen Hartnett        }
  21. {    Ωhm Software Company, 163 Richard Drive, Tiverton, RI 02878    }
  22. {    30 December 1987 OH changed for version 2.00 }
  23.  
  24. program MultiSkel;
  25.  
  26.     uses
  27. {$IFC UNDEFINED THINK_PASCAL}
  28.         Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf, 
  29. {$ENDC}
  30.         MSkelRgn, MultiSkelGlobals, common, TransSkel, MSkelZoom, MSkelEdit, MSkelHelp;
  31.  
  32. { file menu item numbers }
  33.  
  34.     const
  35.         open = 1;
  36.         close = 2;
  37.         quit = 4;
  38.  
  39. {    Menu handles.  There isn't any apple menu here, since TransSkel will}
  40. {    be told to handle it itself.}
  41.  
  42.     var
  43.         filemenu: menuhandle;
  44.  
  45. {    Handle selection of About MultiSkel… item from Apple menu}
  46.  
  47.     procedure DoAbout;
  48.  
  49.         var
  50.             ignore: integer;
  51.     begin
  52.         ignore := Alert(aboutAlrt, nil);
  53.     end;
  54.  
  55. {    Show a window if it's not visible.  Select the window FIRST, then}
  56. {    show it, so that it comes up in front.  Otherwise it will be drawn}
  57. {    in back then brought to the front, which is ugly.}
  58.  
  59.  
  60.     procedure MyShowWindow (wind: WindowPeek);
  61.     begin
  62.         if (wind^.visible = false) then
  63.             begin
  64.                 SelectWindow(WindowPtr(wind));
  65.                 ShowWindow(WindowPtr(wind));
  66.             end;
  67.     end;
  68.  
  69. {    Process selection from File menu.}
  70.  
  71. {    Open    Make all four windows visible}
  72. {    Close    Hide the frontmost window.  If it belongs to a desk accessory,}
  73. {            close the accessory.}
  74. {    Quit    Request a halt by calling SkelHalt().  This makes SkelMain}
  75. {            return.}
  76.  
  77.     procedure DoFile (item: integer);
  78.  
  79.         var
  80.             wPeek: WindowPeek;
  81.  
  82.     begin
  83.         case item of
  84.             open: 
  85.                 begin
  86.                     MyShowWindow(WindowPeek(rgnWind));
  87.                     MyShowWindow(WindowPeek(zoomWind));
  88.                     MyShowWindow(WindowPeek(editWind));
  89.                     MyShowWindow(WindowPeek(helpWind));
  90.                 end;
  91.             close: 
  92.  
  93. {    Close the front window.  Take into account whether it belongs}
  94. {    to a desk accessory or not.}
  95.  
  96.                 begin
  97.                     wPeek := WindowPeek(FrontWindow);
  98.                     if wPeek <> nil then
  99.                         begin
  100.                             if (wPeek^.windowKind < 0) then
  101.                                 CloseDeskAcc(wPeek^.windowKind)
  102.                             else
  103.                                 HideWindow(FrontWindow);
  104.                         end;
  105.                 end;
  106.             quit: 
  107.                 SkelWhoa;        { request halt }
  108.         end;
  109.     end;
  110.  
  111. {    Process item selected from Edit menu.  First check whether it should}
  112. {    get routed to a desk accessory or not.  If not, then for route the}
  113. {    selection to the text editing window, as that is the only one for}
  114. {    this application to which edit commands are valid.}
  115. {    (The test of FrontWindow is not strictly necessary, as the Edit}
  116. {    menu is disabled when any of the other windows is frontmost, and so}
  117. {    this Proc couldn't be called.)}
  118.  
  119.     procedure DoEdit (item: integer);
  120.  
  121.     begin
  122.         if not SystemEdit(item - 1) then        { check DA edit choice }
  123.             if FrontWindow = editWind then
  124.                 EditWindEditMenu(item);
  125.     end;
  126.  
  127. {    Initialize menus.  Tell Skel to process the Apple menu automatically,}
  128. {    and associate the proper procedures with the File and Edit menus.}
  129.  
  130.     procedure SetUpMenus;
  131.  
  132.     begin
  133.         SkelApple('About MultiSkel…', @DoAbout);
  134.         fileMenu := GetMenu(fileMenuRes);
  135.         editMenu := GetMenu(editMenuRes);
  136.         dummy := SkelMenu(fileMenu, @DoFile, nil, false);
  137.         dummy := SkelMenu(editMenu, @DoEdit, nil, true);
  138.     end;
  139.  
  140. begin
  141.     SkelInit(6, nil);
  142.     SetUpMenus;            { install menu handlers }
  143.     RgnWindInit;        { install window handlers  }
  144.     ZoomWindInit;
  145.     EditWindInit;
  146.     HelpWindInit;
  147.     SkelMain;
  148.     SkelClobber;        { throw away windows and menus }
  149. end.